package com.anquing.securitydemo.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;


/**
 * @author wangqq65
 * @since 2021/8/6 11:49
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    @GetMapping("/user/{id}")
    public Object hello(@PathVariable(value = "id") String id) {
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication authentication = context.getAuthentication();
        return authentication;
    }
}
